<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    'use strict';
    function fn(){
      console.log(this);
    }

    let obj2 = {
      name: 'obj2',
      fn(){
        console.log(this);
      }
    }

    //1. 直接调用
    // fn(); // window
    // obj2.fn();// obj2
    // let fn2 = obj2.fn;
    // fn2();

    //2. 声明对象
    let obj = {name: 'obj'};
    // fn.apply(obj);  function(){}  () => {}
    // fn.apply(undefined); //如果不是严格模式则 this 的值为 window, 如果是严格模式, 则 this 的值为 undefined
    obj2.fn.call(obj);

  </script>
</body>
</html>